//============================================================================
// Name        : PatternGenomAnalyser.h
// Author      : Anthea Neums, Jonas Halbach
//			   :
// Description : The Interface of the Class PatternGenomAnalyser analyses the
//				 genom and matches it to a pattern.
//============================================================================

#ifndef PATTERNGENOMANALYSER_H_
#define PATTERNGENOMANALYSER_H_

#include <list>
#include <stdlib.h>
#include <string.h>
#include <vector>

#include "Found.h"
#include "stdafx.h"
#include "FileReader.h"
#include "PatternHandler.h"

namespace algorithm {

typedef list<Found *> List;

//using namespace std;
class PatternGenomAnalyser {
public:
	PatternGenomAnalyser(FileReader *patternSource, FileReader *genomSource, int wordlength, int startpos, int length, int threadNumber);
	virtual ~PatternGenomAnalyser();

	/**
	 * This Method finds matching patterns in a genom.
	 */
	void findSimilarStrings();

	/**
	 * This Method prints the Vector of the founded matches and adds "Ergebnisliste"
	 * at the front and "Ende Ergebnisse" after printing the information about the
	 * founds.
	 */
	void printFounds();
	list<Found *> *getFounds();

	int getThreadNumber();

private:

	/**
	 * This Method prooves if the pattern and the genom are matching over the specified bounds.
	 * @param genomPosition 	: one Position of the genom, where the pattern and the genom match
	 * @param patternPosition 	: one Position in the pattern, where genom and Pattern match.
	 * @param n 				: is the minimal length of matching chars in the genom and pattern.
	 * @return					: An pointer to a Found-object which stores the information about the
	 * 								founded match.
	 */
	Found *findSingleMatch(int genomPosition, int patternPosition);

	/**
	 * This Method prints the Vector of the founded matches and adds a
	 * linenumber to each found.
	 */
	void printMatches();

	list<Found *> *founds;
	PatternHandler *patternHandler;
	FileReader *contentReader;
	FileReader *patternReader;
	Found *lastFound;
	const int wordlength;
	int threadNumber;

	int startpos;
	int length;

};

} /* namespace algorithm */
#endif /* PATTERNGENOMANALYSER_H_ */
